<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <h1 v-if="flag">{{message}}</h1>
        <p v-show="flag">{{name.toUpperCase()}}</p>
        <button v-on:click="count++">+</button>
        <span>{{count}}</span>
        <button @click="count--">-</button>
        <button @click="sh()">切换隐藏</button>
        <span v-show="isShow">methods</span>
        <div>
            <h3>售卖机</h3>
            <button @click="buy(5)">买5元</button>
            <button @click="buy(10)">买10元</button>
            <p>预约：{{money}}</p>
        </div>
    </div>
    <script>
        const app = new Vue({
            el: '#app',
            data:{
                message: 'Hello World',
                name: 'Vue',
                flag: true,
                count: 0,
                isShow: true,
                money: 100
            },
            methods:{
                sh(){
                    this.isShow = !this.isShow
                },
                buy(m){
                    if(this.money >= m){
                        this.money -= m
                    }else{
                        alert('余额不足')

                    }
                }

            }
        })
    </script>
</body>
</html>